#ifndef CHATBUF_H
#define CHATBUF_H
//该类为聊天记录缓存
//存放一个目标的新增聊天记录
//步骤，设置目标oc号，添加记录
//设置oc号时将会写入并清除



#include <QObject>
#include <QList>
#include <QPair>
#include <QTimer>

typedef QList<QPair<QPair<QString,QString>,bool>> Triplet;//三元组
class ChatBuf : public QObject
{
    Q_OBJECT
public:
    static ChatBuf* getInstance();
    QList<QPair<QPair<QString,QString>,bool>> getList();
    void addChat(QString chatoc,QString content,bool sender);
    //void setOC(QString OC);
    //QString getOC();
    void clear();
    bool isEmpty();
signals:
    //oc切换，将缓存写入数据库
    void s_chatListWrite(QList<QPair<QPair<QString,QString>,bool>>);
public slots:
    void freshNow();
private:
    ChatBuf();
    static ChatBuf* chatbuf;
    QList<QPair<QPair<QString,QString>,bool>> chatlist;
    QString oc;
};

#endif // CHATBUF_H
